<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">
		<title>管理员后台</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script type="text/javascript" src="<%=basePath%>js/jquery-1.5.js"
			charset="utf-8">
		</script>
		<script type="text/javascript">

$(function() {

	$("#name").attr("value", "");
	$("#pass").attr("value", "");
	$("#validateCode").attr("value", "");
})
function reloadValidate() {
	$("#validateImage").attr("src",
			"generateValidateCode.action?" + Math.random());
}
function login() {
	if ($("#name").val() == "" || $("#name").val() == null) {
		alert("用户名不能为空");
		return;
	}
	if ($("#pass").val() == "" || $("#pass").val() == null) {
		alert("密码不能为空");
		return;
	}
	if ($("#validateCode").val() == "" || $("#validateCode").val() == null) {
		alert("验证码不能为空");
		return;
	}
	var userName = $("#name").val();
	var password = $("#pass").val();
	var validateCode = $("#validateCode").val();
	$.post("<%=basePath%>json/loginAction", {
		"userName" : userName,
		"password" : password,
		"validateCode" : validateCode,
		"data" : new Date
	}, function(data) {
		if (data.result == "success") {
			location.href = "<%=basePath%>tuserAction!showAll";
		} else {
			alert(data.result)
			reloadValidate();//更换验证码
			$("#validateCode").val("")
		}
	});
}
function reset() {
	$("#name").attr("value", "");
	$("#pass").attr("value", "");
	$("#validateCode").attr("value", "");
}
</script>
		<style type="text/css">
<!--
body,td,th {
	font-family: 微软雅黑, 宋体, Verdana, Arial, Arial Black;
	font-size: 12px;
}

body {
	background-color: #f2f2f2;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}

#main {
	position: absolute;
	top: 50%;
	left: 50%;
	background-image: url(images/admin_login.jpg);
	background-repeat: no-repeat;
	background-position: center center;
	height: 442px;
	width: 422px;
	margin-left: -240px;
	margin-top: -250px;
}

#title {
	font-size: 40px;
	text-align: center;
	position: absolute;
	width: 422px;
	!margin-left:-170px;
}

#con {
	margin-top: 167px;
	margin-left: 185px;
	height: 100px;
}
-->
</style>
	</head>

	<body>

		<div id="main">
			<div id="title">
				新生报到系统后台登录
			</div>
			<div style="padding-top: 147px;margin-left: 183px;margin-top:20px;!margin-top:0px;_margin-top:0px;">
				<form name="msgForm" action="login.action" method="post"	id="loginForm" >
					<input id="name" type="text"
						style="width: 130px; line-height: 20px; height: 20px; border: 0px;_margin-left:84px;" />
					<br />
					<input id="pass" type="password"
						style="width: 130px; line-height: 20px; height: 20px; border: 0px; margin-top: 15px;_margin-left:84px;" />
					<br />
					<input type="text" id="validateCode"
						style="width: 60px; line-height: 20px; height: 20px; border: 0px; margin-top: 13px;_margin-left:84px;" />
					&nbsp;
					<img onclick="reloadValidate();"
						src="generateValidateCode.action?<%=Math.random()%>>"
						id="validateImage" style="_width:70px;" />
		
			<div style="width: 180px;margin-top:10px;margin-right:200px;margin-left:20px;">
				<a href="javascript:login()"><img src="images/OK.gif" border="0"
						onmouseover="this.src='images/OKhover.gif'"
						onmouseout="this.src='images/OK.gif'" /> </a>&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:reset()"><img src="images/cl.gif" border="0"
						onmouseover="this.src='images/clhover.gif'"
						onmouseout="this.src='images/cl.gif'" /> </a>
			</div>
			</form>
		</div>
		</div>
	</body>
</html>
